﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.ServiceModel;
using System.ServiceModel.Description;
using demobackground.LuuDiemService1;
using Microsoft.Phone.Controls;
using Millionaire;
using WindowsFormsApplication1.BLL;
using System.Threading;
using Microsoft.Devices;


namespace demobackground
{
    public partial class MainPage : PhoneApplicationPage
    {
        NguoiChoiBLL ncBLL;

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            ncBLL = new NguoiChoiBLL();
            
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/SettingPage.xaml", UriKind.Relative));
        }

        private void txtBatDau_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            App a = Application.Current as App;
            if (a.IdNguoiChoi == 0)
            {
                NavigationService.Navigate(new Uri("/CreateUser.xaml", UriKind.Relative));
            }
            else
            {
                SoundController.PlaySound("Sound/c1.wav",a.tieng,4500);
                Storyboard sb = new Storyboard() { Duration= TimeSpan.FromSeconds(4.5) };
                sb.Begin();
                sb.Completed += (ds,de) => {
                    NavigationService.Navigate(new Uri("/secondpage.xaml", UriKind.Relative));
                };
                
            }
        }

        private void textBlock2_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/SettingPage.xaml", UriKind.Relative));
        }

        private void hyperlinkButton1_Click(object sender, RoutedEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/CreateUser.xaml", UriKind.Relative));
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            App a = Application.Current as App;
            if (a.IdNguoiChoi != 0)
            {
                txtuser.Text = ncBLL.GetByID(a.IdNguoiChoi).HoTen;
            }
        }

        private void txtLuatChoi_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/RulePage.xaml", UriKind.Relative));
           
        }

        private void txtXepHang_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/ScorePage.xaml", UriKind.Relative));
        }

        private void txtCauHinh_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            NavigationService.Navigate(new Uri("/SoundPage.xaml",UriKind.Relative));
        }

        private void txtTroChoiKhac_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            VibrateController vc = VibrateController.Default;
            vc.Start(TimeSpan.FromSeconds(0.1));
            MessageBox.Show("Chức năng đang trong giai đoạn hoàn thiện", "", MessageBoxButton.OK);
        }
    }
}
